package com.ruoyi.abuwx.controller;

import com.ruoyi.abuwx.domain.AbuwxPersonageRecord;
import com.ruoyi.abuwx.service.IAbuwxPersonageRecordService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 个人记录Controller
 * 
 * @author tang
 * @date 2022-07-02
 */
@RestController
@RequestMapping("/abuwx/AbuwxPersonageRecord")
public class AbuwxPersonageRecordController extends BaseController
{
    @Autowired
    private IAbuwxPersonageRecordService abuwxPersonageRecordService;

    /**
     * 查询个人记录列表
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxPersonageRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(AbuwxPersonageRecord abuwxPersonageRecord)
    {
        startPage();
        List<AbuwxPersonageRecord> list = abuwxPersonageRecordService.selectAbuwxPersonageRecordList(abuwxPersonageRecord);
        return getDataTable(list);
    }

    /**
     * 导出个人记录列表
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxPersonageRecord:export')")
    @Log(title = "个人记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AbuwxPersonageRecord abuwxPersonageRecord)
    {
        List<AbuwxPersonageRecord> list = abuwxPersonageRecordService.selectAbuwxPersonageRecordList(abuwxPersonageRecord);
        ExcelUtil<AbuwxPersonageRecord> util = new ExcelUtil<AbuwxPersonageRecord>(AbuwxPersonageRecord.class);
        util.exportExcel(response, list, "个人记录数据");
    }

    /**
     * 获取个人记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxPersonageRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(abuwxPersonageRecordService.selectAbuwxPersonageRecordById(id));
    }

    /**
     * 新增个人记录
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxPersonageRecord:add')")
    @Log(title = "个人记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AbuwxPersonageRecord abuwxPersonageRecord)
    {
        return toAjax(abuwxPersonageRecordService.insertAbuwxPersonageRecord(abuwxPersonageRecord));
    }

    /**
     * 修改个人记录
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxPersonageRecord:edit')")
    @Log(title = "个人记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AbuwxPersonageRecord abuwxPersonageRecord)
    {
        return toAjax(abuwxPersonageRecordService.updateAbuwxPersonageRecord(abuwxPersonageRecord));
    }

    /**
     * 删除个人记录
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxPersonageRecord:remove')")
    @Log(title = "个人记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(abuwxPersonageRecordService.deleteAbuwxPersonageRecordByIds(ids));
    }
}
